package com.hr.checkrepetition.controller;

import com.hr.checkrepetition.model.dto.ArticleCheckDto;
import com.hr.checkrepetition.model.dto.PostReportDto;
import com.hr.checkrepetition.model.vo.ArticleCheckListVo;
import com.hr.checkrepetition.model.vo.ArticleCheckVo;
import com.hr.checkrepetition.model.vo.ChannelRespVO;
import com.hr.checkrepetition.model.vo.ResponseVO;
import com.hr.checkrepetition.service.ArticleDupCheckService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/repetition")
@Slf4j
@Api(tags = "文章查重")
public class ArticleDupCheckController {

    @Autowired
    private ArticleDupCheckService articleDupCheckService;

    @PostMapping("/check")
    @ApiOperation(value = "开始查重")
    public ResponseVO check(@RequestBody ArticleCheckDto dto){
        articleDupCheckService.check(dto,getUserId());
        return ChannelRespVO.ok();
    }


    @PostMapping("/reportDetails")
    @ApiOperation(value = "内容查重报告")
    public ResponseVO<ArticleCheckVo> reportDetails(@RequestBody PostReportDto dto){
        return ResponseVO.success(articleDupCheckService.reportDetails(dto,getUserId()));
    }

    @PostMapping("/list")
    @ApiOperation(value = "查重列表")
    public ResponseVO<ArticleCheckListVo> list(){
        return ResponseVO.success(articleDupCheckService.list(getUserId()));
    }

    private Integer getUserId() {
        return 666;
    }

}
